/**
 * PageBuilder 侧边栏样式
 * 包含模块库、编辑面板等
 */

.sidebar-edit-wrap {
  width: 320px;
  background-color: #fff;
  border-right: 1px solid var(--border-color);
  position: relative;
  transition: var(--transition);
  box-shadow: var(--shadow-light);
  height: calc(100vh - 70px); /* 设置侧边栏高度，减去头部导航栏高度 */
}

.sidebar-edit-wrap.v-hide {
  margin-left: -320px;
}

.sidebar-edit-wrap .switch-design {
  position: absolute;
  top: 44%;
  right: -20px;
  z-index: 999;
  cursor: pointer;
  background: var(--primary-gradient);
  width: 20px;
  height: 60px;
  line-height: 60px;
  box-shadow: var(--shadow-medium);
  color: #fff;
  border-radius: 0 8px 8px 0;
  transition: var(--transition);
}

.sidebar-edit-wrap .switch-design:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
  transform: translateX(2px);
}

.sidebar-edit-wrap .design-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
}

/* 当没有内容时隐藏整个区域 */
.sidebar-edit-wrap .design-head:empty {
  display: none;
}

/* 模块导航样式 */
.sidebar-edit-wrap .module-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  font-size: 14px;
  color: var(--text-secondary);
}

.sidebar-edit-wrap .nav-left {
  display: flex;
  align-items: center;
}

.sidebar-edit-wrap .nav-right {
  display: flex;
  align-items: center;
}

.sidebar-edit-wrap .current-module-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-edit-wrap .current-module-info .module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sidebar-edit-wrap .current-module-info .module-icon .img-icon {
  width: 28px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-edit-wrap .current-module-info .module-icon .img-icon img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
}

.sidebar-edit-wrap .current-module-info .module-icon i {
  font-size: 28px;
  color: var(--primary-color);
}

.sidebar-edit-wrap .current-module-info .module-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-edit-wrap .nav-item.back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary-color);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.sidebar-edit-wrap .nav-item.back-btn:hover {
  background: rgba(102, 126, 234, 0.08);
  color: #5a6fd8;
}

.sidebar-edit-wrap .nav-item.back-btn i {
  font-size: 12px;
}

/* 响应式模块导航 */
@media (max-width: 768px) {
  .sidebar-edit-wrap .module-nav {
    padding: 8px 12px;
    font-size: 13px;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  
  .sidebar-edit-wrap .nav-left {
    justify-content: center;
  }
  
  .sidebar-edit-wrap .nav-right {
    justify-content: center;
  }
  
  .sidebar-edit-wrap .current-module-info .module-icon {
    width: 20px;
    height: 20px;
  }
  
  .sidebar-edit-wrap .current-module-info .module-icon .img-icon {
    width: 20px;
    height: 20px;
  }
  
  .sidebar-edit-wrap .current-module-info .module-icon i {
    font-size: 20px;
  }
  
  .sidebar-edit-wrap .current-module-info .module-name {
    font-size: 14px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .sidebar-edit-wrap .nav-item.back-btn {
    padding: 4px 8px;
    font-size: 13px;
  }
}

.sidebar-edit-wrap .modules-list {
  background: var(--secondary-color);
  height: calc(100vh - 70px); /* 减去头部导航栏的高度 */
  overflow-y: auto;
  padding: 0;
}

/* 当处于编辑状态时，需要减去design-head的高度 */
.sidebar-edit-wrap .modules-list.with-design-head {
  height: calc(100vh - 70px - 50px); /* 减去头部导航栏和design-head的高度 */
}

.sidebar-edit-wrap .modules-header {
  padding: 16px 12px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.sidebar-edit-wrap .modules-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

/* 响应式设计：在小屏幕上改为垂直布局 */
@media (max-width: 480px) {
  .sidebar-edit-wrap .modules-header-top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
}

.sidebar-edit-wrap .modules-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0; /* 防止标题被压缩 */
}

.sidebar-edit-wrap .modules-search {
  flex: 1; /* 搜索框占据剩余空间 */
  min-width: 0; /* 允许搜索框缩小 */
}

/* 响应式设计：在小屏幕上搜索框占满宽度 */
@media (max-width: 480px) {
  .sidebar-edit-wrap .modules-search {
    flex: none;
    width: 100%;
  }
}

.sidebar-edit-wrap .modules-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sidebar-edit-wrap .modules-categories .el-tag {
  transition: var(--transition);
  cursor: pointer;
}

.sidebar-edit-wrap .modules-categories .el-tag:hover {
  transform: translateY(-1px);
}

.sidebar-edit-wrap .no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.sidebar-edit-wrap .no-results i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.sidebar-edit-wrap .no-results p {
  margin: 0;
  font-size: 14px;
}

.sidebar-edit-wrap .modules-content {
  padding: 12px;
  padding-bottom: 20px; /* 确保底部有足够的空间 */
}

.sidebar-edit-wrap .module-list {
  text-align: center;
  padding: 6px;
  cursor: pointer;
  margin-bottom: 8px;
}

.sidebar-edit-wrap .module-list .module-info {
  background: #fff;
  color: var(--text-primary);
  transition: var(--transition);
  cursor: move;
  border-radius: var(--border-radius);
  border: 2px solid transparent;
  padding: 8px;
  box-shadow: var(--shadow-light);
}

.sidebar-edit-wrap .module-list .module-info:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-heavy);
  transform: translateY(-2px);
}

.sidebar-edit-wrap .module-list .module-info:active {
  transform: translateY(0);
}

.sidebar-edit-wrap .module-list .icon {
  padding: 16px 0 12px;
  height: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-edit-wrap .module-list .icon .img-icon {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-edit-wrap .module-list .icon .img-icon img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
}

.sidebar-edit-wrap .module-list .icon i {
  font-size: 28px;
  color: var(--primary-color);
}

.sidebar-edit-wrap .module-list .name {
  font-size: 13px;
  height: 32px;
  overflow: hidden;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-secondary);
}

/* 模块编辑区域 */
.module-edit {
  padding: 0 16px 20px;
  overflow-y: auto;
  height: calc(100vh - 70px - 50px); /* 设置编辑区域高度，减去头部导航栏和design-head的高度 */
  background: #fff;
}

.module-edit .image-edit-wrapper {
  margin-bottom: 20px;
}

.module-edit .module-editor-row {
  height: 56px;
  line-height: 56px;
  background: var(--primary-gradient);
  padding: 0 24px;
  margin: 0 -16px 20px;
  font-size: 16px;
  color: #fff;
  font-weight: 600;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  box-shadow: var(--shadow-light);
}

.module-edit .module-edit-group {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--secondary-color);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.module-edit .module-edit-group:last-of-type {
  margin-bottom: 0;
}

.module-edit .module-edit-group .module-edit-title {
  margin-bottom: 16px;
  position: relative;
  padding-left: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--text-primary);
}

.module-edit .module-edit-group .module-edit-title:before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 18px;
  background: var(--primary-gradient);
  border-radius: 2px;
}

/* Element UI 组件样式调整 */
.el-form-item {
  margin-bottom: 16px;
}

.el-form-item__label {
  font-weight: 500;
  color: var(--text-primary);
}

.el-input-number {
  width: 100%;
}

.el-switch {
  margin-right: 8px;
} 